package com.nuist.springioc.controller;

import com.nuist.springioc.model.UserInfo;
import com.nuist.springioc.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {

    // 属性注入
    @Autowired
    private UserService userService;

    // AutoWired存在的问题
//    @Qualifier("user2")
//    @Autowired
//    private UserInfo user;
    @Resource(name="user2")
    private UserInfo user;

    public void sayHello() {
        System.out.println("Hello, Controller");
        userService.sayHello();
        System.out.println(user);
    }
}
